import {defineStore} from 'pinia'
export const userStore=defineStore('user',{
   state:()=>({
      user:sessionStorage.getItem("curUser")?JSON.parse(sessionStorage.getItem("curUser")):null
   })
   ,getters:{
      isLogin(state){
        return state.user!=null
      }
   }
   ,actions:{
      saveUser(user){
        this.user=user
        sessionStorage.setItem("curUser",JSON.stringify(this.user))
      },
      removeUser(){
        this.user=null
        sessionStorage.removeItem("curUser")
      }
   }

})